package com.webside.spread.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webside.base.baseservice.impl.AbstractService;
import com.webside.spread.mapper.SpreadMapper;
import com.webside.spread.model.SpreadSupporterEntity;
import com.webside.spread.service.SpreadService;
@Service("SpreadService")
public class SpreadServiceImpl extends AbstractService<SpreadSupporterEntity, Long> implements SpreadService {
	@Autowired
	private SpreadMapper spreadMapper;
	//这句必须要加上。不然会报空指针异常，因为在实际调用的时候不是BaseMapper调用，而是具体的mapper，这里为userMapper
		@Autowired
		public void setBaseMapper() {
			super.setBaseMapper(spreadMapper);
		}
	@Override
	public List<SpreadSupporterEntity> queryAllSpread() {
		// TODO Auto-generated method stub
		return spreadMapper.selectAllSpread();
	}

	@Override
	public int updateSpread(SpreadSupporterEntity spread) {
		spreadMapper.updateSpread(spread);
		int i =0;
		if(!spreadMapper.selectSpread(spread).isEmpty()){
			i=1;
		}
		return i;
	}

	@Override
	public int addSpread(SpreadSupporterEntity spread) {
		spreadMapper.addSpread(spread);
		int i =0;
		if(!spreadMapper.selectSpread(spread).isEmpty()){
			i=1;
		}
		return i;
	}


	@Override
	public List<SpreadSupporterEntity> queryListByPage(java.util.Map<String, Object> param) {
		// TODO Auto-generated method stub
		return spreadMapper.querySpread(param);
	}
	@Override
	public int deleteSpread(List<String> id) {
		
			spreadMapper.deleteSpread(id);
			SpreadSupporterEntity spread = new SpreadSupporterEntity();
			
		int i =1;
		
		return i;
	}
	@Override
	public List<String> selectSpreadName() {
		
		return spreadMapper.selectAllSpreadName();
	}
	@Override
	public List<Map<String,Object>> selectSpreadNameAll() {
		// TODO Auto-generated method stub
		return spreadMapper.selectSpreadName();
	}

	

}
